﻿Imports System.Data
Imports System.Data.SqlClient
Imports DAO
Imports System.Data.OleDb

Public Class DataProvider
    'bien bao loi
    Public _bienbaoloi As String

    Public connection As OleDbConnection
    Public connection_string As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source =../../../PHONGMACHTU.mdb"
    ''ket noi csdl
    Public Function ConnectDB() As OleDbConnection
        connection = New OleDbConnection(connection_string)
        Return connection
    End Function
    ' Do~ du lieu vao` datatable

    Public Function DataApdater(ByVal query As String) As OleDbDataAdapter

        Dim da As OleDbDataAdapter = New OleDbDataAdapter(query, connection)
        Return da
    End Function
    ' neu muon lay 1 danh sach dang datattable
    Public Function Datatable_PHONGMACHTU(ByVal query As String) As DataTable
        'Mo ket noi
        Dim cnn As New OleDbConnection
        cnn = ConnectDB()
        cnn.Open()
        'tao cau truy van
        Dim da As New OleDbDataAdapter()
        da = DataApdater(query)
        Dim dt As New DataTable()
        Try
            da.Fill(dt)

        Catch ex As Exception

        End Try
        cnn.Close()
        Return dt
    End Function


End Class
